<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head th:replace="common/fragment::top">

</head>
<!--采购入库-->
<body>
<div class="lyear-layout-web">
    <div class="lyear-layout-container">
        <!--左侧导航-->
        <div th:replace="common/fragment::leftmenu"></div>
        <!--End 左侧导航-->

        <!--头部信息-->
        <div th:replace="common/fragment::header"></div>
        <!--End 头部信息-->

        <!--页面主要内容-->
        <main class="lyear-layout-content">

            <div class="container-fluid">
                <div class="row">
                    <div class="col-lg-12">
                        <div class="card">
                            <div class="card-toolbar clearfix">
                                <div class="row show-grid">
                                    <div class="col-md-2">
                                        <button class="btn btn-success btn-w-md" id="new-purin-btn" type="button">新建入库单</button>
                                    </div>
                                    <!--占位-->
                                    <div class="col-md-2"></div>
                                    <!--END占位-->
                                    <div class="col-md-8">
                                        <!--供应商列表-->
                                        <div class="dropdown col-md-2" id="supplierlist">
                                            <input type="text" hidden="hidden" id="servforsupplierlist">
                                            <button class="btn btn-primary dropdown-toggle" type="button"  data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
                                                供应商
                                                <span class="caret"></span>
                                            </button>
                                            <ul class="dropdown-menu" aria-labelledby="dropdownMenu1" >
                                                <li><a href="-999"  >任意</a></li>
                                                <li role="separator" class="divider"></li>
                                                <li th:each="sup:${supplierlist}"> <a th:href="${sup.id}"  th:text="${sup.name}" >Action</a></li>

                                            </ul>
                                        </div>
                                        <!--END供应商列表-->
                                        <!--入库单状态下拉菜单-->
                                        <div class="dropdown col-md-2" id="statusid">
                                            <input type="text" hidden="hidden" id="serforstatusid">
                                            <button class="btn btn-primary dropdown-toggle" type="button"  data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
                                                入库单状态
                                                <span class="caret"></span>
                                            </button>
                                            <ul class="dropdown-menu" aria-labelledby="dropdownMenu1" >
                                                <li><a href="-999">任意</a></li>
                                                <li role="separator" class="divider"></li>
                                                <li th:each="status:${purinstatus}" ><a th:href="${status.getKey()}" th:text="${status.getValue()}">Action</a></li>

                                            </ul>
                                        </div>
                                        <!--END入库单状态下拉菜单-->
                                        <!--订单名-->
                                        <div class="col-md-3">
                                            <input class="form-control" id="purname" name="purname" placeholder="订单名" type="text">
                                        </div>
                                        <!--采购入库单名-->
                                        <div class="col-md-3">
                                            <input class="form-control" id="inname" name="inname" placeholder="采购入库单名" type="text">
                                        </div>

                                        <div class="col-md-2">
                                            <button class="btn btn-success btn-w-md" id="purin-search-btn" type="button">搜索</button>
                                        </div>
                                    </div>

                                </div>
                            </div>

                            <div class="card-body">
                                <div class="table-responsive">
                                    <table class="table table-bordered">
                                        <thead >
                                        <tr>
                                            <th>序号</th>
                                            <th hidden="hidden">采购入库单id</th>
                                            <th hidden="hidden">采购单id</th>
                                            <th>供应商</th>
                                            <th>采购单号</th>
                                            <th>采购入库单号</th>
                                            <th>编制日期</th>
                                            <th>要货日期</th>
                                            <th>入库日期</th>
                                            <th>状态</th>
                                            <th>操作</th>
                                        </tr>
                                        </thead>
                                        <tbody id="purdetail">
                                        <tr th:each="purin:${purinlist}">
                                            <td class="purinid" hidden="hidden" th:text="${purin.id}"></td>
                                            <td class="purid" hidden="hidden" th:text="${purin.purPO.id}"></td>
                                            <td th:text="${purinStat.index+1}"></td>
                                            <td th:text="${purin.purPO.supplierPO.name}">供应商</td>

                                            <td th:text="${purin.purPO.name}"></td>
                                            <td th:text="${purin.name}"></td>
                                            <td th:text="${#dates.format(purin.purPO.createTime, 'yyyy-MM-dd')}">编制日期</th>
                                            <td th:text="${#dates.format(purin.purPO.need, 'yyyy-MM-dd')}"></td>
                                            <td th:text="${#dates.format(purin.createTime, 'yyyy-MM-dd')}"></td>
                                            <td th:text="${purinstatus[purin.status]}">状态</td>
                                            <td>
                                                <div class="btn-group">
                                                    <a class="btn btn-xs btn-default"
                                                       data-toggle="tooltip"
                                                       th:href="'/purin/editpurin.do?id='+${purin.id}" title="编辑">
                                                        <i class="mdi mdi-pencil"></i>
                                                    </a>
                                                </div>
                                            </td>
                                        </tr>
                                        </tbody>
                                    </table>
                                </div>
                                <!--
                                <ul class="pagination">
                                  <li class="disabled"><span>«</span></li>
                                  <li class="active"><span>1</span></li>
                                  <li><a href="#1">2</a></li>
                                  <li><a href="#1">3</a></li>
                                  <li><a href="#1">4</a></li>
                                  <li class="disabled"><span>...</span></li>
                                  <li><a href="#!">14452</a></li>
                                  <li><a href="#!">14453</a></li>
                                  <li><a href="#!">»</a></li>
                                </ul>
                                -->
                            </div>
                        </div>
                    </div>

                </div>

            </div>



        </main>
        <!--------------------------------------------------------------------->
       <!-- <main class="lyear-layout-content">
            <div class="container-fluid">
                <div class="toolbar-btn-action">
                    <a class="btn btn-primary m-r-5" href="/stock/addstock.do">
                        <i class="mdi mdi-plus"></i>
                        新增
                    </a>

                </div>
            </div>
            &lt;!&ndash;添加搜索条件&ndash;&gt;
            <div class="form-group col-md-10">

            </div>
            &lt;!&ndash;END添加搜索条件&ndash;&gt;

            &lt;!&ndash;采购入库单列表&ndash;&gt;
            <div id="threshold-table">

                <table class="table table-bordered">
                    <thead id="goodheader">
                    <tr>
                        <th>序号</th>
                        <th hidden="hidden">采购入库单id</th>
                        <th hidden="hidden">采购单id</th>
                        <th>采购单号</th>
                        <th>采购入库单号</th>
                        <th>入库日期</th>
                        &lt;!&ndash;

                        <th>操作</th>&ndash;&gt;
                    </tr>
                    </thead>
                    <tbody id="purdetail">
                    <tr th:each="purin:${purinlist}">
                        <td class="purinid" hidden="hidden" th:text="${purin.id}"></td>
                        <td class="purid" hidden="hidden" th:text="${purin.purPO.id}"></td>
                        <td th:text="${purinStat.index+1}"></td>
                        <td th:text="${purin.purPO.name}"></td>
                        <td th:text="${purin.name}"></td>
                        <td th:text="${purin.createTime}"></td>

                    </tr>
                    </tbody>
                </table>
            </div>
            &lt;!&ndash;END采购入库单列表&ndash;&gt;
        </main>-->
        <!--End 页面主要内容-->
    </div>
</div>

<div th:insert="common/fragment::tail-script"></div>

<style>
    .modify {
        color: #ac2925;
        font-weight: bolder;
    }
</style>

<script type="text/javascript">

$(document).ready(function () {



// 新建采购入库单按钮事件
        $('#new-purin-btn').click(function () {
            window.location.href="/purin/newPurIn.do"
        });
// END 新建采购入库单按钮事件

/**
* 模糊查询
* @type {string}
*/
    // supplierlist 禁止 下拉菜单点击跳转
        let supperid = ''
        $('#supplierlist').find('a').each(function (i,e) {
                $(e).click(function (event) {
                    supperid = $(this).attr('href')
                    let name = $(this).text()
                    $('#supplierlist button' ).text(name)
                    $('#servforsupplierlist').val(supperid)
                    console.log(supperid)
                    event.preventDefault()
                })
        });

    // status 禁止 下拉菜单点击跳转
    let statusid = ''
    $('#statusid').find('a').each(function (i,e) {
        $(e).click(function (event) {
            statusid = $(this).attr('href')
            let name = $(this).text()
            $('#serforstatusid').val(statusid)
            $('#statusid button').text(name)
            event.preventDefault()
        })
    });




        $('#purin-search-btn').click(function (event) {
            // purname 订单名
           let purname = $('#purname').val()
            // inname 入库单名
            let inname = $('#inname').val()
            // 状态id
            let statusid = $('#serforstatusid').val()

            let supplierid =$('#servforsupplierlist').val()

                // 查询组合
            let requestpara = ''

            if(supplierid==='' || supplierid==='-999'){
                supplierid =''
            }

            if(statusid==='' || statusid==='-999'){
                statusid = ''
            }

            if(purname==='' ){
                requestpara = ''
            }

            if(inname==='' ){
                requestpara = ''
            }
            window.location.href = "/purin/purinstock.do?purname="+purname+"&inname="+inname+"&statusid="+statusid+"&supplierid="+supplierid

        });
// END 模糊查询
    });
</script>
</body>
</html>